/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * FenLancementDe.java
 *
 * Created on 9 janv. 2012, 16:13:48
 */

package InterfaceGraphique;
import cartes.Carte;

import java.awt.Color;
import cartes.Monstre;

import java.awt.Toolkit;
import javax.swing.ImageIcon;

import common.Constantes;
import java.awt.Image;
import java.util.ArrayList;
import org.jdesktop.application.Action;

/**
 *
 * @author ophelie.moyssan
 */
public class FenLancementDe extends javax.swing.JFrame {

    private Monstre m;
    /** Creates new form FenLancementDe */
    public FenLancementDe() {
       // this.setBackground(new java.awt.Color(110,48,34));
         this.getContentPane().setBackground(new Color(237,200,132));
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        imageDe = new javax.swing.JLabel();
        message = new javax.swing.JLabel();
        bouton = new javax.swing.JToggleButton();
        texte = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setText("Lancement du dé");
        jLabel1.setName("jLabel1"); // NOI18N

        imageDe.setText("jLabel2");
        imageDe.setName("imageDe"); // NOI18N

        message.setText(" ");
        message.setName("message"); // NOI18N

        bouton.setText("OK");
        bouton.setName("bouton"); // NOI18N
        bouton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                boutonMouseClicked(evt);
            }
        });

        texte.setText("jLabel2");
        texte.setName("texte"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(62, 62, 62)
                .addComponent(jLabel1)
                .addContainerGap(226, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap(77, Short.MAX_VALUE)
                        .addComponent(texte))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(54, 54, 54)
                        .addComponent(message, javax.swing.GroupLayout.DEFAULT_SIZE, 68, Short.MAX_VALUE)))
                .addGap(104, 104, 104)
                .addComponent(imageDe, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(70, 70, 70))
            .addGroup(layout.createSequentialGroup()
                .addGap(132, 132, 132)
                .addComponent(bouton, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(178, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(33, 33, 33)
                .addComponent(jLabel1)
                .addGap(25, 25, 25)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(imageDe, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(21, 21, 21))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(texte)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                .addComponent(message)
                .addGap(8, 8, 8)
                .addComponent(bouton)
                .addContainerGap(50, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    //clique sur le bouton-> renvoie vers la fenetre de perte d'un combat.
    private void boutonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_boutonMouseClicked
                // TODO add your handling code here:
               //revenir à la fenêtre Combat Defaite
              MainApplication.showPerteCombat2();
              this.dispose();
    }//GEN-LAST:event_boutonMouseClicked

   

    public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new FenLancementDe().setVisible(true);


                    }
 });


    }


    public void load(int resultat){

        //affichage de la face du dé
        if ( resultat >= 1 && resultat <= 6){
            ImageIcon imageCarte = new ImageIcon(getClass().getResource("/de/D" + resultat +".gif"));
            ImageIcon imageRedim = new ImageIcon(imageCarte.getImage().getScaledInstance(110, 135, Image.SCALE_DEFAULT));
            this.imageDe.setIcon(imageRedim);
            this.imageDe.setVisible(true);
            
            this.texte.setText("Votre résultat est : " + resultat);

        }     
    }
    

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JToggleButton bouton;
    private javax.swing.JLabel imageDe;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel message;
    private javax.swing.JLabel texte;
    // End of variables declaration//GEN-END:variables

     /**
    * @param args the command line arguments
    */
    


       


}

